package LeetcodeTest_twelve;
//跳跃游戏
//贪心算法
public class canJump
{
    public static void main(String[] args)
    {
        int num[]={3,2,1,0,4};
        System.out.println(solution.canJump(num));
    }
}
class solution
{
    public static boolean canJump(int[] nums)
    {
        int i,j;
        i=nums.length-1;
        j=i-1;
        while(j>=0)
        {
            if(i-j<=nums[j])
            {
                i=j;
                j=i-1;
            }
            else
                j--;
        }
        if(i==0)
            return true;
        else
            return false;
    }
}